package com.sqx.modules.task.controller;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.sqx.common.utils.PageUtils;
import com.sqx.common.utils.Result;
import com.sqx.modules.app.annotation.Login;
import com.sqx.modules.fixedClassify.dao.FixedClassifyDao;
import com.sqx.modules.task.entity.HelpOrder;
import com.sqx.modules.task.entity.HelpTake;
import com.sqx.modules.task.entity.MasterService;
import com.sqx.modules.task.service.HelpOrderService;
import com.sqx.modules.task.service.HelpTakeService;
import com.sqx.modules.task.service.MasterServiceService;
import com.sqx.modules.utils.excel.ExcelData;
import com.sqx.modules.utils.excel.ExportExcelUtils;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * @author fang
 * @date 2023/08/02
 */
@RestController
@Api(value = "师傅关联服务", tags = {"师傅关联服务"})
@RequestMapping(value = "/masterService")
public class MasterServiceController {

    @Autowired
    private MasterServiceService masterServiceService;
    @Autowired
    private FixedClassifyDao fixedClassifyDao;

    @GetMapping("/selectMasterServiceByUserId")
    @ApiOperation("查询师傅关联服务")
    public Result selectMasterServiceByUserId(Long userId){
        List<MasterService> masterServiceList = masterServiceService.list(new QueryWrapper<MasterService>().eq("master_user_id", userId));
        for (MasterService masterService:masterServiceList){
            masterService.setFixedClassify(fixedClassifyDao.selectById(masterService.getClassifyId()));
        }
        return Result.success().put("data",masterServiceList);
    }

    @PostMapping("/updateMasterService")
    @ApiOperation("修改师傅关联服务")
    public Result updateMasterService(String classifyIds,Long userId){
        return masterServiceService.updateMasterService(classifyIds,userId);
    }

    @PostMapping("/deleteMasterService")
    @ApiOperation("删除师傅关联服务")
    public Result deleteMasterService(Long masterServiceId){
        masterServiceService.removeById(masterServiceId);
        return Result.success();
    }

    @PostMapping("/insertMasterService")
    @ApiOperation("添加师傅关联服务")
    public Result insertMasterService(@RequestBody MasterService masterService){
        masterServiceService.save(masterService);
        return Result.success();
    }



}